<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<meta name="decorator" content="default"/>
<script src="${ctxStatic}/js/template/template.js"></script>
<div class="col-lg-12">
<div class="col-xs-4">
    <label style="padding-top: 10px;" class="control-label">退药数量:</label>
</div>
<form:form id="inputForm" data-parsley-validate=""  modelAttribute="applyDrugWithdra"  method="post" class="form-horizontal">
    <form:hidden path="patientId" />
    <form:hidden path="visitId" />
    <form:hidden path="priceId" />
    <form:hidden path="storageId" />
    <form:hidden path="itemClass" />
    <form:hidden path="itemName" />
    <form:hidden path="itemCode" />
    <form:hidden path="itemSpec" />
    <form:hidden path="units" />
    <form:hidden path="amount" id="amount" />
    <form:hidden path="costs" />
    <form:hidden path="charges" />
    <form:hidden path="retType" value="1" />
    <div style="padding-top: 6px;" class="col-xs-8">
        <form:input path="retAmount" id="retAmount" type="number" min="1" htmlEscape="false" class="form-control" onchange="selectAmount()" maxlength="40"
               data-parsley-required="true" data-parsley-type="number" />
    </div>
    </section>
    </div>

    <div class="btn-group">
        <input id="btnSubmit" onclick="parentDivLoad('LeftDiv','inputForm','${ctx}/finance/inpBillDetail/refundList?patientId=${applyDrugWithdra.patientId}&visitId=${applyDrugWithdra.visitId}','${ctx}/applydrugwithdra/save')" class="btn btn-success col-lg-6" type="submit" value="新 方">
    </div>
</form:form>
<script>
//    function selectAmount(){
//        var retAmount =  $("#retAmount").val();
//        var amount =  $("#amount").val();
//        if(retAmount>amount){
//            parent.toastr.error("退药数量大于已有数量");
//        }
//    }

    function parentDivLoad(div,formId, divUrl, url) {
        $("#" + formId).ajaxSubmit({
            type: 'post', // 提交方式 get/post
            url:url, // 需要提交的 url
            success: function(data) { // data 保存提交后返回的数据，一般为 json 数据
                if (data.code == "success") {
                    parent.toastr.success(data.data);
                    parent.layer.closeAll();
                    parent.loadDiv(div, divUrl);
                } else if(data.code == 'info'){
                    parent.layer.close("history");
                    parent.loadDiv(div, divUrl);
                    parent.layer.close("history");
                } else {
                    flag = true;
                    parent.toastr.error(data.data);
                }
            }
        });

    }

</script>